package com.situ.stmall.manger.mapper;

import com.situ.stmall.manger.entity.Admin;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface AdminMapper {

/*    int inset(Admin admin);

    int delete(int id);*/

    /**
     * update
     * @param admin
     * @return
     */
    @Update("<script>" +
            "update admin" +
            "<set>" +
            "<if test='password!=null and password.length()>0'> password=#{password},</if>" +
            "<if test='salt!=null and salt.length()>0'>salt=#{salt},</if>" +
            "<if test='phone!=null and phone.length()>0'>phone=#{phone},</if>" +
            "<if test='email!=null and email.length()>0'>email=#{email}',</if>" +
            "<if test='realname!=null and realname.length()>0'>realname=#{realname},</if>" +
            "<if test='status!=null'>status=#{status},</if>" +
            "</set>" +
            "where id = #{id}"+
            "</script>")
    int update(Admin admin);

    /**
     *
     * @param username
     * @return
     */
    @Select("select * from admin where username = #{username}")
    Admin selectAdminByusername(String username);

    /**
     *
     * @param id
     * @return
     */
    @Select("select * from admin where id = #{id}")
    Admin selectAdminById(int id);
}
